<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const obj1 = {
        name: "laowang",
        age: 18,
      };

      //Object.defineProperty给对象去添加或者修改某个属性,并且可以给属性设置描述
      Object.defineProperty(obj1, "name", {
        value: "laowang",
        writable: false,
        enumerable: false,
      });
      obj1.name = "xiaowang";

      console.log(obj1);
    </script>
  </body>
</html>
